#!/bin/bash
./xmlchange CLM_USRDAT_NAME=NEON
# CLM_USRDAT_NAME can be set to either NEON or NEON.PRISM
./xmlchange CCSM_CO2_PPMV=408.83
# Set data forcing data to future scenario so will have data from 2018 to present-day
./xmlchange DATM_PRESAERO=SSP3-7.0
./xmlchange DATM_PRESNDEP=SSP3-7.0
./xmlchange DATM_PRESO3=SSP3-7.0
# Explicitly set the MPI library to mpi-serial so won't have the build/run complexity of a full MPI library
./xmlchange MPILIB=mpi-serial
# Set years to run forcing data over
./xmlchange DATM_YR_ALIGN=2018,DATM_YR_END=2021,DATM_YR_START=2018
#
# Save some variables that may be used later
#
compset=`./xmlquery COMPSET --value`
CLM_USRDAT_NAME=`./xmlquery CLM_USRDAT_NAME --value`
TEST=`./xmlquery TEST --value`

# For a transient case run the whole length and don't cycle
if  [[ $compset =~ ^HIST ]]; then
  ./xmlchange CALENDAR=GREGORIAN
  ./xmlchange DATM_YR_END=2022
  ./xmlchange RUN_STARTDATE=2018-01-01
  # Number of months that can be run for the full transient case
  if [[ $TEST != "TRUE" ]]; then
    ./xmlchange STOP_OPTION="nmonths"
    ./xmlchange STOP_N=51
  fi
  ./xmlchange CLM_NML_USE_CASE="2018-PD_transient"
else
  ./xmlchange CLM_NML_USE_CASE="2018_control"
  ./xmlchange CALENDAR=NO_LEAP
fi

# If needed for SP simulations: & set history file variables
if [[ $compset =~ .*CLM[0-9]+%[^_]*SP.* ]]; then
  if [[ $TEST != "TRUE" ]]; then
    ./xmlchange STOP_OPTION=nyears
  fi
  ./xmlchange CLM_FORCE_COLDSTART=on

  echo "hist_fincl2 = 'FCEV','FCTR','FGEV','FIRA','FSA','FSH','FPSN','H2OSOI','SNOW_DEPTH','TBOT','TSOI'" >> user_nl_clm 
fi

# Explicitly set PIO Type to NETCDF since this is a single processor case (should already be set this way)
./xmlchange PIO_TYPENAME=netcdf

./xmlchange NEONVERSION="v2"
